package com.audaque.springboot.foshanupload.authcore.service.impl;

import com.audaque.springboot.foshanupload.authcore.constants.AuthConst;
import com.audaque.springboot.foshanupload.authcore.model.currentUser.TransmittableThreadLocalCurrentUser;
import com.audaque.springboot.foshanupload.authcore.service.inface.UserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @author zgb
 * @desc ...
 * @date 2023-07-14 16:45:26
 */
@Service
public class UserServiceImpl implements UserService {
    @Value("${db.tenantId}")
    private String tenantId;

    //校验登录表单
    public Boolean validLoginForm(TransmittableThreadLocalCurrentUser transmittableThreadLocalCurrentUser) {
        //查数据库校验用户账号和密码
        return true;
    }

    public String getUserIdByUsername(String username) {
        return AuthConst.USER_ID;
    }

    public TransmittableThreadLocalCurrentUser getUserByUsername(String username) {
        //根据用户名查用户是否存在，不存在则抛异常
        TransmittableThreadLocalCurrentUser transmittableThreadLocalCurrentUser = new TransmittableThreadLocalCurrentUser();
        transmittableThreadLocalCurrentUser.setId(AuthConst.USER_ID);
        transmittableThreadLocalCurrentUser.setTenantId(tenantId);
        transmittableThreadLocalCurrentUser.setUsername(AuthConst.USERNAME);
        transmittableThreadLocalCurrentUser.setPassword(AuthConst.PASSWORD);
        return transmittableThreadLocalCurrentUser;


    }

}
